package com.qf.service.impl;

import com.qf.domain.SysMenu;
import com.qf.mapper.SysMenuMapper;
import com.qf.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class SysMenuServiceImpl implements SysMenuService {

    @Autowired
    SysMenuMapper menuMapper;

    @Override
    public Set<String> findPermsByUserId(int id) {
        List<SysMenu> menuList= menuMapper.findPermsByUserId(id);
        // 通过lambda  stream 把List<SysMenu> 转换为 Set<String>
        //Collectors.toSet() 指定 目标集合类型
        //map：映射， 返回值，集合中的元素
        Set<String> perms = menuList.stream().map((e) -> {
            return e.getPerms();
        }).collect(Collectors.toSet());
        return perms;
    }
}